package com.zmn.oms.third.baidu_app;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 百度小程序同步状态的常量参数和配置定义
 *
 * @author xiewenbing
 * @date 2020/08/31
 */
@Component
public class BaiduAppConsts {

    /**
     * 渠道名称
     */
    public final static String CHANNEL_NAME = "百度小程序";

    /**
     * 渠道同步开关
     */
    public static boolean POWER_ON = true;

    /**
     * app id
     */
    public static String APP_ID = "18763417";

    /**
     * app key
     */
    public static String APP_KEY = "mXWxfymXexkD9BIlXbFQZscL2fvoRXhz";

    /**
     * app secret
     */
    public static String APP_SECRET = "G8nGMwGB9whbG5TbFvuf0UyE07H0fGib";

    /**
     * app url
     */
    public static String APP_URL = "https://openapi.baidu.com/rest/2.0/smartapp/ordercenter/app/";

    /**
     * 获取token的url
     */
    public static String TOKEN_URL = "https://openapi.baidu.com/oauth/2.0/token";

    /**
     * 订单详情跳转链接地址
     */
    public static String APP_ORDER_DETAIL_ADDR = "baiduboxapp://swan/mXWxfymXexkD9BIlXbFQZscL2fvoRXhz/pagesA/order/detail/?id=%oms_order_id%&status=&_baiduboxapp=%7B%22from%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&callback=_bdbox_js_275&upgrade=0";

    /**
     * 导入订单的url path
     */
    public final static String SYNC_NEW_ORDER_PATH = "add/main/info";

    /**
     * 更新订单的url path
     */
    public final static String SYNC_UPDATE_ORDER_PATH = "update/main/info";

    /**
     * 更新状态的url path
     */
    public final static String SYNC_UPDATE_STATUS_PATH = "update/main/status";

    /**
     * 新单录入状态定义值
     */
    public final static int STATUS_NEW_ORDER = 2;

    /**
     * 订单确认状态定义值
     */
    public final static int STATUS_ORDER_CONFIRM = 4;

    /**
     * 订单完成状态定义值
     */
    public final static int STATUS_ORDER_FINISH = 200;

    /**
     * 订单取消状态定义值
     */
    public final static int STATUS_ORDER_CANCEL = 100;

    /**
     * 订单种类 - 10 ,上门服务类型
     */
    public final static int CATE_ID = 10;

    /**
     * 支付方式 - 2 货到付款
     */
    public final static int PAY_METHOD = 2;

    /**
     * 发送成功的返回值
     */
    public final static int RESPONSE_CODE_SUCCESS = 0;

    /**
     * token保存redis的有效时间
     */
    public final static int TOKEN_TIMEOUT = 3600 * 24;

    @Value("${BaiduApp.service.powerOn:false}")
    public void setPowerOn(boolean powerOn){
        POWER_ON = powerOn;
    }

    @Value("${BaiduApp.service.appId:18763417}")
    public void setAppId(String appId){
        APP_ID = appId;
    }

    @Value("${BaiduApp.service.appKey:mXWxfymXexkD9BIlXbFQZscL2fvoRXhz}")
    public void setAppKey(String appKey){
        APP_KEY = appKey;
    }

    @Value("${BaiduApp.service.appSecret:G8nGMwGB9whbG5TbFvuf0UyE07H0fGib}")
    public void setAppSecret(String appSecret){
        APP_SECRET = appSecret;
    }

    @Value("${BaiduApp.service.appUrl:https://openapi.baidu.com/rest/2.0/smartapp/ordercenter/app/}")
    public void setAppUrl(String appUrl){
        APP_URL = appUrl;
    }

    @Value("${BaiduApp.service.tokenUrl:https://openapi.baidu.com/oauth/2.0/token}")
    public void setTokenUrl(String tokenUrl){
        TOKEN_URL = tokenUrl;
    }
}